package com.bwie.service.impl;
import com.bwie.dao.SeckillDao;
import com.bwie.entity.Seckill;
import com.bwie.service.SeckillService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SeckillServiceImpl implements SeckillService {
    @Autowired
    private SeckillDao seckillDao;


    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public PageInfo<Seckill> list(Integer pageNum, Integer pageSize) {

//        List<Seckill> list1 = seckillDao.list();
//        ValueOperations ops = redisTemplate.opsForValue();
//        for (Seckill seckill : list1){
//            ops.set("secList",seckill);
//        }
        PageHelper.startPage(pageNum,pageSize);
        List<Seckill> list = seckillDao.list();
        return new PageInfo<>(list);
    }

    @Override
    public Seckill findBySeckillByMid(Integer id) {
        return seckillDao.findBySeckillByMid(id);
    }

    @Override
    public Seckill findSeckillById(Integer id) {
        return seckillDao.findSeckillById(id);
    }
}
